<?php
// +----------------------------------------------------------------------
// | ThinkPHP [ WE CAN DO IT JUST THINK ]
// +----------------------------------------------------------------------
// | Copyright (c) 2006~2017 http://thinkphp.cn All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: 李邦琦 <1536549251@qq.com>
// +----------------------------------------------------------------------

namespace app\crm\model;
use think\Db;
use think\Model;
use think\Cache;
use think\Loader;

class Hotline extends Model
{
    /**
     * 获取客户资料列表
     * @param str $where <查询条件>
     * @param int $page <页码>
     * @param int $limit <每页显示条数>
     * @return array <日报列表信息>
     */
    public function hotlineResourcesData($where,$page,$limit)
    {
        $menuname = "Hotline Resources";
        $p_menuname = $_SESSION['menu'][$menuname]; //父菜单
        $priv = $_SESSION["user_priv"][$p_menuname][$menuname]; 
        $username = $_SESSION["user_info"]["username"];

        $users = Cache::get('users');
        $member = Cache::get('member');
        // $department = Cache::get('department');
        $fields = "r.*,c.name,c.integral,c.member_Level";
        $count = Db::table('bgcrm.hotline_record')->alias('r')->join('xy_vip_customer_basic c','r.customer_id = c.customer_code')->field($fields)->where($where)->count();
        // 查询状态为1的用户数据 并且每页显示10条数据
        $customerList = Db::table('bgcrm.hotline_record')->alias('r')->join('xy_vip_customer_basic c','r.customer_id = c.customer_code')->field($fields)->where($where)->limit(($page-1)*$limit,$limit)->select();
        // print_r($customerList);exit;
        foreach ($customerList as &$val) {
            // $val['create_name'] = $users[$val['create_user']]['cn_name'];
        }
        $rowsList = count($customerList) ? $customerList : false;
        $arrData["code"] = 0;
        $arrData["msg"] = '';
        $arrData["count"] = $count;
        $arrData["data"] = $rowsList;
        return $arrData;
    }



}